﻿using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using ZeroSum.Domain.Entities;

namespace ZeroSum.Plugin.Authorization.Datas.Aggregates.UserAggregate;

public class UserBase : BaseEntity<long>, ISoftDelete
{
    /// <summary>
    ///     账号
    /// </summary>
    [DisplayName("账号")]
    [Required]
    [MaxLength(20)]
    public virtual string? Account { get; set; }

    /// <summary>
    ///     获取或设置 账号
    /// </summary>
    [DisplayName("标准化的账号")]
    public virtual string? NormalizeAccount { get; set; }

    /// <summary>
    ///     密码（默认MD5加密）
    /// </summary>
    [DisplayName("密码")]
    [Required]
    [MaxLength(50)]
    public virtual string? Password { get; set; }

    /// <summary>
    ///     昵称
    /// </summary>
    [DisplayName("昵称")]
    [MaxLength(20)]
    public virtual string? NickName { get; set; }

    /// <summary>
    ///     姓名
    /// </summary>
    [DisplayName("姓名")]
    [MaxLength(20)]
    public virtual string? Name { get; set; }

    /// <summary>
    ///     头像
    /// </summary>
    [DisplayName("头像")]
    public virtual string? Avatar { get; set; }

    /// <summary>
    ///     生日
    /// </summary>
    [DisplayName("生日")]
    public virtual DateTime? Birthday { get; set; }

    /// <summary>
    ///     性别-男_1、女_2
    /// </summary>
    [DisplayName("性别-男_1、女_2")]
    [Required]
    public virtual Gender Sex { get; set; }

    /// <summary>
    ///     邮箱
    /// </summary>
    [MaxLength(50)]
    [Required]
    [DisplayName("电子邮箱")]
    [DataType(DataType.EmailAddress)]
    public virtual string? Email { get; set; }

    /// <summary>
    ///     获取或设置 标准化的电子邮箱
    /// </summary>
    [DisplayName("标准化的电子邮箱")]
    [DataType(DataType.EmailAddress)]
    public virtual string? NormalizeEmail { get; set; }

    /// <summary>
    ///     获取或设置 表示用户是否已确认其电子邮件地址的标志
    /// </summary>
    [DisplayName("电子邮箱确认")]
    public virtual bool EmailConfirmed { get; set; } = false;

    /// <summary>
    ///     手机
    /// </summary>
    [DisplayName("手机")]
    [MaxLength(20)]
    [Required]
    public virtual string? Phone { get; set; }

    /// <summary>
    ///     获取或设置 手机号码是否已确认
    /// </summary>
    [DisplayName("手机号码确定")]
    public virtual bool PhoneNumberConfirmed { get; set; } = false;

    /// <summary>
    ///     电话
    /// </summary>
    [DisplayName("电话")]
    [MaxLength(20)]
    public virtual string? Tel { get; set; }

    /// <summary>
    ///     获取或设置 是否锁定当前信息
    /// </summary>
    [DisplayName("是否锁定")]
    public virtual bool IsLocked { get; set; } = false;

    /// <summary>
    ///     获取或设置 当任何用户锁定结束时，UTC的日期和时间。
    /// </summary>
    [DisplayName("锁定时间")]
    public virtual DateTime? LockoutEnd { get; set; }

    /// <summary>
    ///     获取或设置 当前用户失败的登录尝试次数。
    /// </summary>
    [DisplayName("登录失败次数")]
    public virtual int AccessFailedCount { get; set; }

    /// <summary>
    ///     获取或设置 是否系统管理员
    /// </summary>
    [DisplayName("是否系统管理员")]
    public virtual bool IsAdmin { get; set; } = false;

    /// <summary>
    ///     最后登录IP
    /// </summary>
    [DisplayName("最后登录IP")]
    [MaxLength(20)]
    public virtual string? LastLoginIp { get; set; }

    /// <summary>
    ///     最后登录时间
    /// </summary>
    [DisplayName("最后登录时间")]
    public virtual DateTime? LastLoginTime { get; set; }

    public bool IsDeleted { get; set; }

    public override string? ToString()
    {
        return Account;
    }
}